/*
 * Alexey Danchuk
 * This software is an implementation of the task from OOP module.
 */
package parser;

import input.ManualInput;
import static parser.Parser.QUESTION_REPRESENTATION;

/**
 * This class describes basics issues about manual question input parse.
 *
 * @version 2.03 20 February 2013
 * @author Alexey Danchuk
 */
public class ManualParser extends Parser {

    private String[][] manualData = null;
    private ManualInput input;

    @Override
    public void parse() throws Exception {
        makeRepresentation();
    }

    private void makeRepresentation() throws Exception {
        input = new ManualInput();
        input.input();
        String[] inputedData = input.getInputFromUser();
        int rows = inputedData.length / QUESTION_REPRESENTATION;
        int columns = QUESTION_REPRESENTATION;
        if ((rows % 3) == 0) {
            manualData = new String[rows][columns];
            for (int index = 0; index < inputedData.length; index++) {
                int column = index % columns;
                int row = (index - column) / columns;
                manualData[row][column] = inputedData[index];
            }
        } else {
            System.err.println("Error with your inputed data.");
        }
    }

    /**
     * @return the manualData
     */
    public String[][] getManualData() {
        return manualData;
    }
}
